using System;
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI.SmartParts;
using Microsoft.Practices.ObjectBuilder;
using Jbe.TestSuite.Infrastructure.Interface;
using Jbe.TestSuite.TestDevice.FunctionGen.ControlView.Services;
using Jbe.TestSuite.TestDevice.FunctionGen.Interface.Services;
using Jbe.CABExtension.WinForms;
using Jbe.TestSuite.TestDevice.FunctionGen.ControlView.Constants;

namespace Jbe.TestSuite.TestDevice.FunctionGen.ControlView.Views
{
    public partial class FunctionGenView : UserControl, IFunctionGenView
    {
        private ConfigurationView configurationView;

        public IFunctionGenConfig Config
        {
            set { configurationView.Config = value; }
        }

        public FunctionGenView()
        {
            InitializeComponent();

            configurationView = new ConfigurationView();
            configurationView.Dock = DockStyle.Fill;
            configPanel.Controls.Add(configurationView);
        }

        public void UpdateIsActive(bool active)
        {
            activeText.Text = active ? "Yes" : "No";
            startButton.Enabled = !active;
            stopButton.Enabled = active;
        }

        protected override void OnLoad(EventArgs e)
        {
            presenter.OnViewReady();
            base.OnLoad(e);

            CommandHelper.AddInvoker(presenter.WorkItem, CommandNames.ConfigureFunctionGen, configureButton);
        }

        private void StartButtonClick(object sender, EventArgs e)
        {
            presenter.Start();
        }

        private void StopButtonClick(object sender, EventArgs e)
        {
            presenter.Stop();
        }
    }
}

